package com.cms.handler;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.cms.report.RepDataHandlerService;

@Component("playSettingHandlerBean")
public class PlaySettingHandlerService implements RepDataHandlerService 
{

	@Override
	public Object handlerRepData(List<Map<String, Object>> srcData, Map<String, Object> query) throws Exception 
	{
		List<Map<String, Object>>playGroups = new ArrayList<Map<String,Object>>();
		Map<String, Map>groupMap = new HashMap<String, Map>();
		Map<String, Object>temp =null;
		List<Map> data = null;
		if(srcData!=null&&!srcData.isEmpty())
		{
			 for(Map<String, Object>group:srcData)
			 {
				 if(groupMap.containsKey(group.get("id")+""))//已存在
				 {
					 ((List)groupMap.get(group.get("id")+"").get("playList")).add(group);
				 }
				 else
				 {
					 temp = new HashMap<String, Object>();
					 temp.putAll(group);
					 data = new ArrayList<Map>();
					 data.add(group);
					 temp.put("playList", data);
					 groupMap.put(group.get("id")+"", temp);
					 playGroups.add(temp);
				 }
			 }
		}
		return playGroups;
	}

}
